import Taro from '@tarojs/taro'


//渐变
export function fadeinInit() {
  let select = Taro.createAnimation({
    duration: 500,
    timingFunction: 'ease',
    delay: 0,
  });
  select.opacity(0).step()
  return select
}

//渐变
export function fadein() {
  let select = Taro.createAnimation({
    duration: 2500,
    timingFunction: 'ease',
    delay: 0,
    // transformOrigin: 'left top 0',
    success: (res) => {

    }
  });
  select.opacity(0).step().opacity(0.5).step().opacity(0.8).step().opacity(1).step()
  return select
}

//垂直滑动 渐入渐出
export function slideupshow(that, param, px, opacity) {
  let select = Taro.createAnimation({
    duration: 800,
    timingFunction: 'ease',
  });
  select.translateY(px).opacity(opacity).step()
  let json = '{"' + param + '":""}'
  json = JSON.parse(json);
  json[param] = select.export()
  that.setState(json)
}

//平行滑动 渐入渐出
export function sliderightshow(px, opacity) {
  let select = Taro.createAnimation({
    duration: 1500,
    timingFunction: 'ease',
  });
  select.translateX(px).opacity(opacity).step()
  return select
}

export function rotate() {
  let select = Taro.createAnimation({
    // 动画持续时间，单位ms，默认值 400
    duration: 1000,
    /**
     * http://cubic-bezier.com/#0,0,.58,1
     *  linear  动画一直较为均匀
     *  ease    从匀速到加速在到匀速
     *  ease-in 缓慢到匀速
     *  ease-in-out 从缓慢到匀速再到缓慢
     *
     *  http://www.tuicool.com/articles/neqMVr
     *  step-start 动画一开始就跳到 100% 直到动画持续时间结束 一闪而过
     *  step-end   保持 0% 的样式直到动画持续时间结束        一闪而过
     */
    timingFunction: 'linear',
    // 延迟多长时间开始
    delay: 100,
    /**
     * 以什么为基点做动画  效果自己演示
     * left,center right是水平方向取值，对应的百分值为left=0%;center=50%;right=100%
     * top center bottom是垂直方向的取值，其中top=0%;center=50%;bottom=100%
     */
    transformOrigin: 'left top 0',
    success: (res) => {

    }
  })
  select.rotate(150).step().scale(2).step().translate(10).step().skew(10).step().opacity(0.5).width(10).step({ducation: 8000})
  return select
}
